<?php
class MY_Model extends CI_Model
{

	public static $slave_client;
	public static $master_client;
	public function __construct()
	{
		parent::__construct();
	}

	//主库
	public function getMaster()
	{
		//
		if(self::$master_client)
		{
			return self::$master_client;
		}

		self::$master_client =  $this->load->database('default', true);
		return self::$master_client;
	}

	//从库
	public function getSlave()
	{
		if(self::$slave_client)
		{
			return self::$slave_client;
		}

		self::$slave_client =  $this->load->database('default', true);
		return self::$slave_client;
	}

	public function getDatabaseHashKey($key = '')
	{
		return 'default';
	}
}